package com.project.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.daos.AdminVehicleMapper;
import com.project.entity.Vehicle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class AdminVehicleService {

    @Autowired
    private AdminVehicleMapper adminVehicleMapper;


    public PageInfo<Vehicle> selAllVehicle(Integer currentPage,Integer pageSize){
        PageHelper.startPage(currentPage,pageSize);
        List<Vehicle> vehicles = adminVehicleMapper.selAllVehicle();
        PageInfo<Vehicle> vehiclePageInfo = new PageInfo<>(vehicles);
        return vehiclePageInfo;
    }

    public PageInfo<Vehicle> selConditionVehicle(String keyWord,Integer currentPage,Integer pageSize){
        PageHelper.startPage(currentPage,pageSize);
        List<Vehicle> vehicles = adminVehicleMapper.selConditionVehicle(keyWord);
        PageInfo<Vehicle> vehiclePageInfo = new PageInfo<>(vehicles);
        return vehiclePageInfo;
    }
}
